using System.Collections;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;

public class EnemyDummy : Enemy
{
    public float rebirthTime = 2f;
    public float healTime = 5f;

    private Coroutine coroutine;
    private FinalDamageInfo heal;

    protected override void Start()
    {
        base.Start();

        heal = new FinalDamageInfo
        {
            Source = this,
            Target = this,
            DamageType = 0,
            FinalDamage = 0,
        };

        AddImmunity<Buff_Knockback>();
    }

    protected override void Death()
    {
        StartCoroutine(DelayAction(rebirthTime, Birth));
    }

    public override float TakeDamage(FinalDamageInfo info, bool canFeedback)
    {
        if (coroutine != null) StopCoroutine(coroutine);
        heal.FinalDamage = Stats[STATS.maxHealth].Value();
        coroutine = StartCoroutine(DelayAction(healTime, () => TakeHeal(heal)));

        return base.TakeDamage(info, canFeedback);
    }
}
